import request from '@/utils/request'
import { encryptedData } from '@/utils/encrypt'
import { loginRSA, tokenName } from '@/config'

export async function login(data) {
  // if (loginRSA) {
  //   data = await encryptedData(data)
  // }
  return request({
    url: `/security/doLogin`,
    method: 'post',
    data,
  })
}

export function getUserInfo() {
  return request({
    url: '/jigou/treeFromLoginUser',
    method: 'post'
  })
}

export function logout() {
  return request({
    url: '/logout',
    method: 'post',
  })
}

export function register() {
  return request({
    url: '/register',
    method: 'post',
  })
}
export function getUserList(data) {
  return request({
    url: '/yonghu/queryYonghuAsPage',
    method: 'post',
    data
  })
}
export function getUserJSList(data) {
  return request({
    url: '/juese/queryJueseAsPage',
    method: 'post',
    data
  })
}

export function getCaidantree(data) {
  return request({
    url: '/caidan/getTree',
    method: 'post',
    headers: { 'content-Type': 'multipart/form-data' },
    data
  })
}
export function getuserauth(data) {
  return request({
    url: '/juese/getJueseQuxian',
    method: 'post',
    headers: { 'content-Type': 'multipart/form-data' },
    data
  })
}
export function getuserauthID(data) {
  return request({
    url: '/juese/getJueseQuxianID',
    method: 'post',
    headers: { 'content-Type': 'multipart/form-data' },
    data
  })
}
export function Updateuserauth(data) {
  return request({
    url: '/juese/updateJueseQuxian',
    method: 'post',
    headers: { 'content-Type': 'multipart/form-data' },
    data
  })
}
export function deleteJuese(data) {
  return request({
    url: '/juese/delete',
    method: 'post',
    headers: { 'content-Type': 'multipart/form-data' },
    data
  })
}

export function saveMenu(data) {
  return request({
    url: '/caidan/add',
    method: 'post',
    headers: { 'content-Type': 'multipart/form-data' },
    data
  })
}
export function updateMenu(data) {
  return request({
    url: '/caidan/update',
    method: 'post',
    headers: { 'content-Type': 'multipart/form-data' },
    data
  })
}
export function doDeleteCaidan(data) {
  return request({
    url: '/caidan/delete',
    method: 'post',
    headers: { 'content-Type': 'multipart/form-data' },
    data
  })
}
